package com.yanze.mvvmlearndemo.moudles;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yanze.mvvmlearndemo.BR;
import com.yanze.mvvmlearndemo.R;
import com.yanze.mvvmlearndemo.utils.ToastUtils;

/**
 * Created by MrZheng on 2018/3/12.
 */

public class ArticleBean extends BaseObservable {
    /**
     * articleId : 4F1DEC797DFC4E438EC7DAD338A1ED22
     * title : 一篇文章看懂保险基础知识
     * bannerImage : /7ECFCC8EB22B40268DCAC578D19A7AF1.png
     * hotKey :
     * content : 人的一生，从幼年接受教育，到事业发展结婚生子，到退休生活幸福晚年，就应该快快乐乐顺顺利利，实现目标和梦想
     * type : 1
     * countSee : 232
     * countCollect : 14
     * source : 网络
     * createTime : 1517988441
     * createUserIp : 192.168.5.109
     * isDel : 0
     * articlesOrder : 0
     */

    private String articleId;
    private String title;
    private String bannerImage;
    private String hotKey;
    private String content;
    private int type;
    private int countSee;
    private int countCollect;
    private String source;
    private int createTime;
    private String createUserIp;
    private int isDel;
    private int articlesOrder;
    private int count = 0;

    public void onItemClick(View view) {
        ToastUtils.showToast(view.getContext(), title);
        setTitle("哈哈哈哈哈哈哈" + String.valueOf(count++));
    }

    @BindingAdapter("articleImg")
    public static void articleImg(ImageView iv, String imgUrl) {
        Glide.with(iv.getContext()).load(imgUrl).placeholder(R.drawable.placeholder_img).into(iv);
    }

    public String getArticleId() {
        return articleId;
    }

    public void setArticleId(String articleId) {
        this.articleId = articleId;
    }

    @Bindable
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
        notifyPropertyChanged(BR.title);
    }

    public String getBannerImage() {
        return bannerImage;
    }

    public void setBannerImage(String bannerImage) {
        this.bannerImage = bannerImage;
    }

    public String getHotKey() {
        return hotKey;
    }

    public void setHotKey(String hotKey) {
        this.hotKey = hotKey;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getCountSee() {
        return countSee;
    }

    public void setCountSee(int countSee) {
        this.countSee = countSee;
    }

    public int getCountCollect() {
        return countCollect;
    }

    public void setCountCollect(int countCollect) {
        this.countCollect = countCollect;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public int getCreateTime() {
        return createTime;
    }

    public void setCreateTime(int createTime) {
        this.createTime = createTime;
    }

    public String getCreateUserIp() {
        return createUserIp;
    }

    public void setCreateUserIp(String createUserIp) {
        this.createUserIp = createUserIp;
    }

    public int getIsDel() {
        return isDel;
    }

    public void setIsDel(int isDel) {
        this.isDel = isDel;
    }

    public int getArticlesOrder() {
        return articlesOrder;
    }

    public void setArticlesOrder(int articlesOrder) {
        this.articlesOrder = articlesOrder;
    }
}
